<!---
	Title:		Elders Program Database
	Author:		Bruce Frick
	Purpose:	Handle prior authorization
--->

<cfset BASE = CreateObject("component", "cfc.base") />
<cfparam name="SESSION.ElderID" default="0">
<cfparam name="url.ElderID" default="0">
<cfparam name="url.PriorAuthID" default="-1">


<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlHeader("/jquery/ui-1.8.5/jquery-ui.min.js,js/priorauth.js", 
	"css/style.css,/jquery/ui-1.8.5/themes/base/jquery-ui.css", "Elders Program - Prior Authorization")#
<!---HTML header, css links, js links, and page title--->

<cfform id="myform" >

<cfset QUERIES.PriorAuths = CreateObject("component", "cfc.queries").funcQrySelectPriorAuthsByElder(SESSION.ElderID)/>
<cfset QUERIES.PriorAuth = CreateObject("component", "cfc.queries").funcQrySelectPriorAuthsByID(url.PriorAuthID)/>
<cfset QUERIES.elder = CreateObject("component", "cfc.queries").funcQryGetIntakeByID(url.ElderID) />
<cfset SESSION.ElderID = url.ElderID />
<cfset UTILITIES = CreateObject("component", "cfc.utilities") />

<cfinput type="hidden" id="ElderID" name="ElderID" value="#SESSION.ElderID#" />
<cfinput type="hidden" id="PriorAuthID" name="PriorAuthID" value="#url.PriorAuthID#" />

<table width="99%" cellpadding="2" cellspacing="2" id="prior_authorization">
	<tbody class="header_title">
        <tr>
            <td valign="top" width="75%">
            	<h2>Prior Authorization</h2>
            </td>
            <td valign="top">         
            	<cfselect id="prior_auths" name="prior_auths" >
                	<option value="-1">- New Prior Authorization -</option>
                <cfloop query="QUERIES.PriorAuths">
                	<option value="#QUERIES.PriorAuths.PriorAuthID#"
                    <cfif QUERIES.PriorAuth.PriorAuthID eq QUERIES.PriorAuths.PriorAuthID>selected="selected"</cfif>>
                    	#dateFormat(QUERIES.PriorAuths.PriorAuthDate, 'mm/dd/yyyy')#
                    </option>
                </cfloop>
                </cfselect>
            </td>
        </tr>
    </tbody>
</table>


<table width="99%" cellpadding="2" cellspacing="2" id="prior_authorization"  >
    <tbody>
    	<tr>
        	<td class="black_spacer">Elder Information</td>
        </tr>
        <tr>
        	<td>
                <table width="100%" cellpadding="2" cellspacing="2" id="prior_authorization" >
                    <tbody>
                        <tr>
                            <td>
                                Elder's Name:
                                <cfselect id="elder" name="elder" >
                                    <option value="-1">- Choose Elder -</option>
                              <cfset QUERIES.eldersNoContact = CreateObject("component", "cfc.queries").funcQryAllEldersNoContacts() />
                                <cfloop query="QUERIES.eldersNoContact">
                                    <cfif SESSION.ElderID eq ELDERLISTID>                    	
                                        <option value="#ELDERLISTID#" selected="selected">#LASTNAME#, #FIRSTNAME#</option>
                                    <cfelse>
                                        <option value="#ELDERLISTID#">#LASTNAME#, #FIRSTNAME#</option>
                                    </cfif>                	
                                </cfloop>
                                </cfselect>
                            </td>
                            <td >
                                <span style="float:left; padding:2px">Date of Birth: </span>
                                <cfinput type="text" id="dob" name="dob" disabled="disabled" size="10"
                                value="#QUERIES.elder.DOB#" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
    <tbody>
    	<tr>
        	<td class="black_spacer">Prior Authorization Information</td>
        </tr>
        <tr>
        	<td>
                <table width="100%" cellpadding="2" cellspacing="2" id="prior_authorization" >
                    <tbody>
                        <tr>
                        	<td width="50%">
                            	Authorization Date:
                                <cfinput type="text" name="PriorAuthDate" 
                                value="#dateFormat(QUERIES.PriorAuth.PriorAuthDate, 'mm/dd/yyyy')#" />
                            </td>
                            <td>
                            	Authorization Number:
                                <cfinput type="text" name="AuthNum" value="#QUERIES.PriorAuth.AuthNum#" />
                            </td>                            
                        </tr>
                        <tr>
                        	<td>
                            	Service Authorized:
                                <cfset sauth = QUERIES.PriorAuth.ServiceAuthorized />                                
                                <cfselect name="ServiceAuthorized" >
                                	<option value="Chore" <cfif sauth eq 'Chore'> selected="selected"</cfif>>Chores</option>
                                    <option value="Meal" <cfif sauth eq 'Meal'> selected="selected"</cfif>>Meals</option>
                                    <option value="Transportation" <cfif sauth eq 'Transportation'> selected="selected"</cfif>>
                                    	Transportation</option>
                                    <option value="TTCM" <cfif sauth eq 'TTCM'> selected="selected" </cfif>>TTCM</option>
                                </cfselect>
                            </td>
                            <td>
                            	## of Units Authorized:
                                <cfinput type="text" name="AuthUnits" value="#QUERIES.PriorAuth.AuthUnits#" />
                            </td>                            
                        </tr>
                        <tr>
                        	<td>
                            	Authorized From Date:
                                <cfinput type="text"  name="FromDate"
                                value="#dateFormat(QUERIES.PriorAuth.FromDate, 'mm/dd/yyyy')#" />
                            </td>
                            <td>
                            	Authorized Thru Date:
                                <cfinput type="text" name="ThruDate" 
                                value="#dateFormat(QUERIES.PriorAuth.ThruDate, 'mm/dd/yyyy')#" />
                            </td>                            
                        </tr>
                        <tr>
                        	<td>
                            	PA Locked:
                                <cfselect name="PALocked" >
                                	<option value="0" <cfif QUERIES.PriorAuth.PALocked eq 0> selected="selected"</cfif>>No</option>
                                    <option value="1" <cfif QUERIES.PriorAuth.PALocked eq 1> selected="selected"</cfif>>Yes</option>
                                </cfselect>
                            </td>
                            <td>
                            	Unbilled Units Remaining:
                                <cfinput type="text" name="RemUnits" value="#QUERIES.PriorAuth.RemUnits#" />
                            </td>                            
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
                 
<div>
<br />
<cfinput type="button" name="save_auth" value="Save Prior Authorization"  />
<cfset UTILS.supervisor = CreateObject("component", "cfc.utilities").funcIsSupervisor(CGI.AUTH_USER)/>
<cfif UTILS.supervisor.RecordCount gt 0 >
	<cfinput type="button" id="edit_auth" name="edit_auth"  value="Edit Prior Authorization" />
	<cfinput type="button" id="delete_auth" name="delete_auth"  value="Delete Prior Authorization" />
</cfif>
</div>

<!---this holds the logged in user for data submition.--->
<input type="hidden" id="signer" value="#CGI.AUTH_USER#" />
<input type="hidden" id="ElderStaffSignature" value="#CGI.AUTH_USER#" />

<!---this holds todays date for data submition.--->
<input type="hidden" id="sign_date" value="#dateFormat(now(),'mm/dd/yyyy')#" />
<input type="hidden" id="SignatureDate" value="#dateFormat(now(),'mm/dd/yyyy')#" />
<input type="hidden" id="NoteDate" value="#dateFormat(now(),'mm/dd/yyyy')#" />
</cfform>



<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlFooter()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>